package me.xpyex.plugin.fixprimordialpearl;

import java.util.HashMap;
import java.util.UUID;
import java.util.logging.Logger;
import org.bukkit.plugin.java.JavaPlugin;

public final class FixPrimordialPearl extends JavaPlugin {
    public final static HashMap<UUID, String> PLAYERS_CHECKING = new HashMap<>();  //多种拦截消息
    public static Logger LOGGER;
    public static FixPrimordialPearl INSTANCE;

    @Override
    public void onDisable() {
        LOGGER.info("已卸载");
        //
    }

    @Override
    public void onEnable() {
        LOGGER = getLogger();
        INSTANCE = this;
        if (!getServer().getVersion().contains("1.12.2")) {
            LOGGER.info("你的服务器版本不是1.12.2，本插件无法处理其它版本，取消加载");
            getPluginLoader().disablePlugin(INSTANCE);
            return;
        }

        try {
            Class.forName("net.minecraftforge.common.MinecraftForge");
        } catch (ClassNotFoundException ignored) {
            LOGGER.info("你的服务器中没有Forge，无需加载此插件.");
            getPluginLoader().disablePlugin(INSTANCE);
            return;
        }

        try {
            Class.forName("thaumcraft.Thaumcraft");
        } catch (ClassNotFoundException ignored) {
            LOGGER.info("你的服务器中没有安装ThaumCraft[神秘时代] Mod，无需加载此插件.");
            getPluginLoader().disablePlugin(INSTANCE);
            return;
        }

        try {
            Class.forName("crazypants.enderio.base.EnderIO");
            getServer().getPluginManager().registerEvents(new FixEnderIO(), INSTANCE);
            LOGGER.info("你的服务器安装了EnderIO，启用EnderIO保护");
        } catch (ClassNotFoundException ignored) {
        }

        getServer().getPluginManager().registerEvents(new HandleEvent(), INSTANCE);
        LOGGER.info("加载完成");
        LOGGER.info("如发现有某些Mod的铁砧绕过本插件，或出现Bug，请联系作者适配 QQ 1723275529");
        CheckUpdate.checkUpdate();
    }
}
